import 'dart:convert';

import 'package:json_annotation/json_annotation.dart';

import 'package:flutter_ume_kit_mock/data/model/mock.dart';
part 'case.g.dart';

@JsonSerializable()
class MockCase {
  String? id;
  CaseFields? fields;

  @JsonKey(ignore: true)
  List<Mock>? mocks;

  @JsonKey(ignore: true)
  bool enable = false;

  MockCase();

  factory MockCase.fromJson(Map<String, dynamic> json) =>
      _$MockCaseFromJson(json);

  Map<String, dynamic> toJson() => _$MockCaseToJson(this);

  @override
  String toString() {
    return jsonEncode(this);
  }
}

@JsonSerializable()
class CaseFields {
  String? title;
  String? module;
  String? desc;
  List<CaseMock>? mock;

  CaseFields();

  factory CaseFields.fromJson(Map<String, dynamic> json) =>
      _$CaseFieldsFromJson(json);

  Map<String, dynamic> toJson() => _$CaseFieldsToJson(this);

  @override
  String toString() {
    return jsonEncode(this);
  }
}

@JsonSerializable()
class CaseMock {
  List<String>? record_ids;

  CaseMock();

  factory CaseMock.fromJson(Map<String, dynamic> json) =>
      _$CaseMockFromJson(json);

  Map<String, dynamic> toJson() => _$CaseMockToJson(this);

  @override
  String toString() {
    return jsonEncode(this);
  }
}
